﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HMI.Header
{
    /// <summary>
    /// MsgboxFrm.xaml 的交互逻辑
    /// </summary>
    public partial class MsgboxFrm : Window
    {
        public MsgboxFrm()
        {
            InitializeComponent();
            tit.CloseFrm += (object sender, RoutedEventArgs e) => {
                this.Close();
            };
            tit.MinFrm += (object sender, RoutedEventArgs e) => {
                this.WindowState = WindowState.Minimized;
            };
            tit.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) =>
            {
                switch (e.ClickCount)
                {
                    case 1:
                        this.DragMove();
                        break;
                }
            };
        }
        public string LabelTxt
        {
            get { return Convert.ToString(tit.TitleName); }
            set { tit.TitleName = value; }
        }
        public string TxtContent
        {
            get
            {
                FlowDocument document = lab.Document;
                TextRange textRange = new TextRange(document.ContentStart, document.ContentEnd);
                string content = textRange.Text;
                return Convert.ToString(content);
            }
            set
            {
                lab.Document.Blocks.Clear();
                lab.AppendText(value);
            }
        }
        bool _isConfim = false;
        public bool IsConfim
        {
            get { return _isConfim; }
            set
            {
                _isConfim = value;
            }
        }
        public Action<bool> DEvent { get; set; }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            IsConfim = true;
            if (DEvent != null)
            {
                DEvent(true);
                this.Close();
            }
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            IsConfim = false;
            if (DEvent != null)
            {
                DEvent(false);
                this.Close();
            }
        }
    }
}
